package pers.fulsun.demo.springcloud.controller;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import pers.fulsun.demo.springcloud.entity.UserTotal;
import pers.fulsun.demo.springcloud.service.UserTotalService;
import pers.fulsun.demo.springcloud.service.impl.UserTotalServiceImpl;

import java.util.Map;

/**
 * <p>TODO
 *
 * @author fulsun
 * @date 2021/9/11
 */
@RestController
public class TestFeignController {
    @Autowired
    private TestFeignIntercept testFeignIntercept;

    @Autowired
    private UserTotalServiceImpl userTotalService;

    @GetMapping("/hello")
    public String hello() {
        return "hello world";
    }

    /**
     * 获取信息
     *
     * @return
     */
    @GetMapping("/testFeign/{id}")
    public Map getFeignMessage(@PathVariable("id") Long id) {
        return this.testFeignIntercept.getFeignMassage(id);
    }
    /**
     * 新增用户的总数
     * @param name 用户名
     * @return
     */
    @PostMapping("/addUserTotal")
    public Boolean addClient(String name) {
        this.userTotalService.incr(name);
        return Boolean.TRUE;
    }
}

